//模块主窗口
ModifyPassPanel = Ext.extend(Ext.Panel,{
	 closable: true,
   	 autoScroll:true,
   	 width:'100%',
   	 layout:'column',
   	 frame:true,
   	 initComponent : function() {
   				this.editPassPanel =  new Ext.Window({
		   			layout:"fit",
		   			title:"修改密码",
		   			closeAction: 'hide',
					resizable:false,
					modal:true,
					width:350,
					height:150,
					items :[new EditMyPasswordForm()]
   				});
				this.items =[{xtype:'label',text:"请输入原始密码："},
				             {
				            	 xtype:'textfield',
				            	 width:150,
				            	 ref:"password"
				             },{xtype:'label',width:20,text:''},{
				            	 xtype:"button",
				            	 text:"确定",
				            	handler:this.checkPassword
				             }]
			
   		ModifyPassPanel.superclass.initComponent.call(this);
   	},
   	checkPassword:function(btn) {
   		 var password = btn.ownerCt.password.getValue();
   		 Ext.Ajax.request({
				method : 'POST',
				params : {
					password:password
				},
				url : 'user_checkPassword.action',
				success : function(request) {
					var Result=Ext.decode(request.responseText);
					if(Result.success) {
						var tform = btn.ownerCt.editPassPanel;
						tform.show();
					} else{
						Ext.Msg.alert("错误","密码错误~~" );
					}
					
				},
				failure : function() {
					Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
				}
		 });
   	}
});


//按条件查询高额用户
EditMyPasswordForm = Ext.extend(Ext.form.FormPanel,{
	layout:"form",
	region : "center",
	labelAlign:"right",
	frame:true,
	initComponent: function(){
	this.items=[{fieldLabel : '新 密 码',
							name : 'user.password',
							allowBlank:false,
							xtype : 'textfield',
							inputType: 'password',
							anchor:"90%"
						},{fieldLabel : '确认密码',
							name : 'password2',
							allowBlank:false,
							inputType: 'password',
							xtype : 'textfield',
							validator:function(v) {
								var pass = this.ownerCt.ownerCt.find("name","user.password")[0].getValue();
								if(v==pass){
									return true;
								}
								return "两次密码不一致~";
							},
							anchor:"90%"
						}
		];
	  EditMyPasswordForm.superclass.initComponent.call(this);
	},
	buttonAlign :'center',
	minButtonWidth:60,
	buttons:[{
		text:"确定",
		handler : function(btn){
		     var thisForm = btn.ownerCt.ownerCt.getForm();
		     if(!thisForm.isValid()) {
		    	 return ;
		     }
			 thisForm.submit({
					waitTitle : '请稍候...',
					waitMsg : '正在提交表单数据,请稍候...',
					method : 'post',
					url:'user_editPass.action?type=my',
					success : function(form, action) {
						btn.ownerCt.ownerCt.ownerCt.hide();
						Ext.Msg.alert("提示", "密码修改成功~~!");
					}
		    });
		}
	}, {
		text : '取消',
		handler : function() {this.ownerCt.ownerCt.ownerCt.hide();}
	}]
});